﻿/* ***************************************************************************************
 * Linq To SystemSearch
 * 
 *
 * This is an example of how extend LinQ using IQueruable and IOrderedQuerable interfaces.
 * 
 * User this code as you want,  is free.
 * 
 * Develop by: Mario Rodriguez
 * email: marior666@hotmail.com
 * 
 ********************************************************************************************/


using System.Reflection;

namespace System.Search.Linq
{
    /// <summary>
    /// 
    /// </summary>
    /// 
    [Serializable]
    internal class ColumnMappingInfo
    {

        /// <summary>
        /// Colum Index of the DataSet
        /// </summary>
        public int ColumIndex { get; set; }
        /// <summary>
        /// Type of object to assign the property
        /// </summary>
        public Type ObjectType { get; set; }
        /// <summary>
        /// Property information of Object container
        /// </summary>
        public PropertyInfo PropertyInfo { get; set; }
        /// <summary>
        /// Property information of the object type
        /// </summary>
        public PropertyInfo ObjectProperty { get; set; }
        /// <summary>
        /// DataSet Column Name
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// Return true if the column is part of an inner object
        /// </summary>
        public bool HasToConvert { get { return ObjectType != null; } }

        /// <summary>
        /// Create a new instance of the inner object
        /// </summary>
        /// <returns>Object create using the ObjectType type</returns>
        public object CreateInstance()
        {
            if (ObjectType != null)
                return Activator.CreateInstance(ObjectType);

            return null;
        }

    }
}
